#include <stdio.h>
#include <string.h>
#include<set>

#define MAXN 3000005
using namespace std;
set<__int128_t>mp[2];
__int128_t chu;
char s[MAXN];
int n, f[1 << 21][2], ans;
bool fl = 0;
int main()
{
    freopen("song.in","r",stdin);
    freopen("song.out","w",stdout);

    scanf("%s", s);
    n = strlen(s);
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] == s[i + 1])
        {
            fl = 1;
            break;
        }
    }
    if (n>20 and !fl)
    {
        if (n & 1)
        {
            printf("%d", n / 2 + 1);
        }
        else
        {
            if (s[0] == 'B')
                printf("%d", n / 2 + 1);
            else
                printf("%d", n / 2);
        }
        return 0;
    }
    for (int i = 0; i < n; i++)
    {
        chu <<= 1;
        chu += s[i] - 'A';
    }
    // memset(f,0,sizeof(f));
    mp[(n/2)&1].insert(chu);
    ans++;
    for (int len = n; len >= 0; len -= 2)
    {
        int i = (len / 2) & 1;
        for (auto j:mp[i])
        {
            for (int k = 1; k < len; k++)
            {
                unsigned long long tmp = (1 << (k - 1)) - 1, t1 = tmp & j, t2 = j;
                t2 = t2 >> (k + 1) << (k - 1);
                t2 += t1;
                // 
                if ((((j >> (k - 1)) & 1) == 0) or (((j >> (k - 1)) & 1) == 1 and ((j >> (k)) & 1) == 1))
                {
                    
                    if (!mp[i^1].count(t2))
                    {
                        //printf("%llu %llu %llu %llu\n", j, t1, t2, tmp);
                        ans++;
                        mp[i ^ 1].insert(t2);
                    }
                }
            }
        }
        mp[i].clear();
    }
    printf("%d", ans);
    return 0;
}